package com.sunwayworld.basemodule.coredata.pjproductpackage.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.coredata.pjproductpackage.dao.LimsTestPackageDao;
import com.sunwayworld.basemodule.coredata.pjproductpackage.bean.LimsTestPackageBean;
import com.sunwayworld.basemodule.coredata.pjproductpackage.service.LimsTestPackageService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsTestPackageServiceImpl implements LimsTestPackageService {

    @Autowired
    private LimsTestPackageDao limsTestPackageDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsTestPackageDao getDao() {
        return limsTestPackageDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsTestPackageBean limsTestPackage = jsonWrapper.parseUnique(LimsTestPackageBean.class);
        limsTestPackage.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsTestPackage);
        return limsTestPackage.getId();
    }

}
